package bytezero.threadexer;



/**
 *
 * 创建 三个窗口 买票  总票数为 100张  使用继承Thread类的方式
 * @author Bytezero1·zhenglei!    Email:420498246@qq.com
 * create  2021-10-15 16:59
 */
class Window extends Thread{

    private static int ticket = 100;

    @Override
    public void run() {
        while (true){

            if(ticket > 0){
                System.out.println(Thread.currentThread().getName() + ":卖票，票号为："+ticket);
                ticket--;
            }else{
                break;
            }
        }
    }
}


public class WindowTest {
    public static void main(String[] args) {
        Window w1 = new Window();
        Window w2 = new Window();
        Window w3 = new Window();

        w1.setName("窗口1");
        w2.setName("窗口2");
        w3.setName("窗口3");

        w1.start();
        w2.start();
        w3.start();

    }

}
